home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
comms
/
other
/
gs_hint
/
hint.amirx
< prev
Wrap
Text File
|
1999-05-17
|
9KB
|
323 lines
/* Hint.amirx v1.1
//
// --- DEDICATED TO PEACE --- NO MORE WAR ---
//
// copyright (c) 1998-1999 George Stagakis (gallant@pathfinder.gr)
//
// changes in v1.1:
// · Added 'bonus round' (optional) Every once in a while the game starts
// in 'bonus round' mode. The score added to the winner is randomly
// more than 3 and less than 7 points instead of a single point.
// Just to increase adrenaline :P
// · Added 'winning score' (optional) When a player reaches this score,
// he wins the game and the score board is cleared for a new start.
// · Added 'top players' (optional) Only shows best top n players in
// the score board, but the whole score board remains in memory.
//
// description:
// Multiplayer hint/scramble game (v1.1) for AmIRC.
//
// The scrambler gives out an answer and a question. The answer
// is displayed scrambled to the players and the question is
// clear. The first one to find the answer receives a point.
// For entering the game, the player just needs to answer a question
// and win a point. That puts him in the score board and in the game.
// No other operations are required. The score board clears whenever
// the scrambler wants it, or when 'timeout loss' or 'score melting'
// throws away all of the players, or when a player reaches
// 'winning score' (wins the game).
//
// The game starts and ends when a player answers correctly. However, the
// score board remains in memory. There are also a few tricks to make it
// more interesting and more active like 'timeouts', 'score melting' and
// 'bonus round'. Also an ability to show only the best players in the
// score board instead of all of them.
// Public displays are very few making it more compact and fun without
// flooding the channels.
//
// usage:
// Put Hint.amirx in AmIRC:Rexx/
// /ALIAS Hint /RX Hint
//
// /HINT answer : question [-n]
// answer: The answer to be displayed scrambled. It can contain spaces
// and such.
// question: The question to be displayed clear. Put anything you want.
// -n: Game starts normally but the score board is cleared completely.
//
// demo:
// /HINT Rolling Stones : Famous rock band.
// <nick> | [unscramble]: oRnglil esSnto
// <nick> | [hint]: Famous rock band.
// <bbb> | rolling stone
// <ccc> | roling stones
// <aaa> | rolling stones
// <nick> | Correct aaa: Rolling Stones
// <nick> | [score]: [aaa - 7] [bbb - 6] [ccc - 5] [ddd - 3] [eee - 1]
//
// notes:
// Freely distributable
// Requires rexxtricks.library 38.6 or greatest
// Options editable in script
// E-mails welcome
// Not sure if it works :P Try everything and then bug me
//
// history:
// (06-Oct-98) 0.9 First version
// (05-May-99) 1.0 First public release
// (08-May-99) 1.1 Added 'bonus round', 'winning score' and 'top players'
//
*/
/* traps */
options results;signal on syntax;signal on break_c;signal on halt
/* options */
winscore = 20 /* winning score. when a player reaches this, game finishes
and scoreboard is cleared (0=Off) */
topplayers = 10 /* only show the best n players in the scoreboard (0=Off) */
timeout = 1 /* times out game after 'timelimit' seconds (0=No,1=Yes) */
timelimit = 30 /* seconds to timeout (if active) */
timeloss = 3 /* points every player loses after timeout (if active) */
meltscore = 1 /* decrease 'meltpoints' points on every round on players
that haven't played for 'meltrounds' rounds (0=No,1=Yes) */
meltpoints = 1 /* points to decrease on meltscore (if active) */
meltrounds = 7 /* rounds to meltscore (if active) */
bonusround = 1 /* bonus rounds. score +3 to +7 instead of +1 sometimes */
debug = 0
script = 'Hint'
/* libraries */
if ~openlib('rexxtricks.library',10) then exit
/* setup */
/* () */
/* program */
parse arg text
if text = '' then cechox('Usage: /HINT answer : question [-n]')
if word(text,words(text)) = '-n' then do
call setclip('hint_score')
text = delword(text,words(text))
end
otext = text
ctext = upper(otext)
parse var text ans' : 'que
nans = ''
do i=1 to words(ans)
nans = nans' 'scramble(word(ans,i))
end
nans = strip(nans)
'ISCONNECTED'
if rc = 5 then cechox("Not connected to a server, can't run Hint.")
channel = getchannel()
cnt = 0
uscore = getclip('hint_score')
if uscore ~= '' then do
do i=1 to words(uscore) by 3
cnt = cnt + 1
users.cnt = word(uscore,i)' 'word(uscore,i+1)' 'word(uscore,i+2)
end
end
bo = bold('[')
bc = bold(']')
scoreadd = 1
bonustext = ''
if rxtr_rand(1,6) = 6 & bonusround = 1 then do
scoreadd = rxtr_rand(3,7);bonustext = 'BONUS ROUND 'bold('+'scoreadd)' - '
end
csend('/MSG 'channel' 'bonustext||bo||underline('unscramble')||bc': 'nans)
csend('/MSG 'channel' 'bo||underline('hint')||bc': 'que)
call time('r')
do forever
'GETLINE'
utext = upper(substr(line.rest,2))
parse var line.prefix nick'!'.
if utext = upper(ans) then do
csend('/MSG 'channel' Correct 'nick': 'ans)
npos = chknick(nick)
if npos = 0 then do
cnt = cnt + 1
score = scoreadd
users.cnt = nick' 'score' 0'
end
else do
parse var users.npos .' 'score' 'age
score = score + scoreadd
age = 0
users.npos = nick' 'score' 'age
end
users.0 = cnt
call rxtr_qsort('users',,'NUM',2)
ustr = ''
uscore = ''
do i=cnt to 1 by -1
parse var users.i u1' 'u2' 'u3
u3 = u3 + 1
if u3 > meltrounds & meltscore = 1 then u2 = u2 - meltpoints
if u2 > 0 then do
users.i = u1' 'u2' 'u3
ustr = ustr' 'bo||word(users.i,1)' - 'word(users.i,2)||bc
uscore = uscore' 'users.i
end
end
ustr = strip(ustr)
if (words(ustr) > topplayers*3) & (topplayers > 0) then ustr = subword(ustr,1,topplayers*3)
uscore = strip(uscore)
csend('/MSG 'channel' 'bonustext||bo||underline('score')||bc': 'ustr)
call setclip('hint_score',uscore)
if (score >= winscore) & (winscore > 0) then do
csend('/MSG 'channel' 'bo'*'bc' WINNER 'bo'*'bc' 'bold(nick)' wins the game!')
call setclip('hint_score')
end
exit
end
if time(e) > timelimit & timeout = 1 then do
csend('/MSG 'channel' Too late! Correct: 'ans)
users.0 = cnt
call rxtr_qsort('users',,'NUM',2)
ustr = ''
uscore = ''
do i=cnt to 1 by -1
parse var users.i u1' 'u2' 'u3
u2 = u2 - timeloss
u3 = u3 + 1
if u3 > meltrounds & meltscore = 1 then u2 = u2 - meltpoints
if u2 > 0 then do
users.i = u1' 'u2' 'u3
ustr = ustr' 'bo||word(users.i,1)' - 'word(users.i,2)||bc
uscore = uscore' 'users.i
end
ustr = strip(ustr)
uscore = strip(uscore)
end
if (words(ustr) > topplayers*3) & (topplayers > 0) then ustr = subword(ustr,1,topplayers*3)
if ustr = '' then ustr = 'no scorer'
csend('/MSG 'channel' 'bo||underline('score')||bc': (losing 'timeloss' points) 'ustr)
call setclip('hint_score',uscore)
exit
end
end
exit
/* custom functions */
scramble: procedure
parse arg text
stext = text
if length(text) > 1 then do until stext ~= text
do 3
otext = text
if length(text) > 1 then do until otext ~= text
lng = length(text)+3
do i=1 to length(text)
rnd = rxtr_rand(1,lng)
rnd2 = rxtr_rand(1,lng)
a = substr(text,rnd,1)
text = delstr(text,rnd,1)
text = insert(a,text,rnd2-1)
end
text = space(text,,0)
end
end
end
return text
chknick: procedure expose users. cnt
parse arg nick
do i=1 to cnt
if upper(nick) = upper(word(users.i,1)) then return i
end
return 0
wait: /* functional flood protection */
do 2000;end
return 1
lower:
return translate(arg(1),xrange('a','z'),xrange('A','Z'))
csend:
cdo(arg(1))
wait()
return 1
cechox:
cecho(arg(1))
exit
/* global functions */
chop:
cdo('/OP' arg(1))
return 0
cmsg:
cdo('/NOTICE' arg(1))
return 0
cdo:
if ~debug then 'SAY' arg(1)
else cecho(arg(1))
return 0
craw:
if ~debug then 'RAW' arg(1)
else cecho(arg(1))
return 0
cecho:
'echo P='d2c(27)'b«'script'» TEXT='arg(1)
return 0
ciecho:
'echo P='d2c(27)'b«'script'» C=3 TEXT='arg(1)
return 0
getmynick:
'GETMYNICK'
return result
getusers:
'GETUSERS CHANNEL='arg(1)
return result
getchannel:
'GETCHANNEL'
return result
openlib: procedure